<template>
  <div class="count">
    <h2>当前求和为：{{ sum }},放大是10倍后{{ bigSum }}</h2>
    <h3>欢迎来到：{{ school }}</h3>
    <h3>学校大写：{{ upperSchool }}</h3>
    <h3>坐落于：{{ address }}</h3>
    <select v-model.number="n">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
    </select>
    <button @click="add">加</button>
    <button @click="minus">减</button>
  </div>
</template>

<script setup lang="ts" name="Count">
import { ref } from "vue";
import { storeToRefs } from "pinia";
import { useCountStore } from "@/store/count";
const countStore = useCountStore();

const { sum, school, address, bigSum, upperSchool } = storeToRefs(countStore);

let n = ref(1); // 用户选择的数字

function add() {
  countStore.sum += 1;
}
function minus() {
  countStore.sum -= n.value;
}
</script>

<style scoped>
.count {
  background-color: skyblue;
  padding: 10px;
  border-radius: 10px;
  box-shadow: 0 0 10px;
}
select,
button {
  margin: 0 5px;
  height: 25px;
}
</style>
